Fix CARGO_INCREMENTAL semantics to be intuitive
authorMalte Schwarzkopf <ms705-git@srcf.ucam.org>
Mon, 13 Feb 2017 00:56:41 +0000 (19:56 -0500)
committerMalte Schwarzkopf <ms705-git@srcf.ucam.org>
Mon, 13 Feb 2017 00:56:41 +0000 (19:56 -0500)
Previously, the mere presence of a CARGO_INCREMENTAL variable in the
environment caused incremental compilation to happen. This has the very
unintuitive effect that `CARGO_INCREMENTAL=0` and even
`CARGO_INCREMENTAL=` mean incremental compilation is *on*.

This change brings the semantics in line with how they are defined in
the tests (cf. tests/build.rs:45), and in public-facing documentation
(https://internals.rust-lang.org/t/incremental-compilation-beta/4721).

src/cargo/ops/cargo_rustc/context.rs

index 4ecd6a7e503d92a3e066468dad40c220b1c35531..31606eb522426304f52985df0846fdc5426ff968 100644 (file)
@@ -78,7 +78,10 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
         // Enable incremental builds if the user opts in. For now,
         // this is an environment variable until things stabilize a
         // bit more.
-        let incremental_enabled = env::var("CARGO_INCREMENTAL").is_ok();
+        let incremental_enabled = match env::var("CARGO_INCREMENTAL") {
+            Ok(v) => v == "1",
+            Err(_) => false,
+        };
 
         Ok(Context {
             ws: ws,